<?php

class JS_AddNode extends JS_Node {
	
	public function __construct($val) {
		parent::__construct($val);
	}
	
	public function interpret() {
		// check if we need to do string concatenation
		if (is_string($this->children[0]->interpret()) || is_string($this->children[1]->interpret())) {
			return $this->children[0]->interpret() . $this->children[1]->interpret();
		}
		else {
			return $this->children[0]->interpret() + $this->children[1]->interpret();
		}
	}
	
	public function __toString() {
		return $this->children[0] . ' + ' . $this->children[1];
	}
	
}

?>